<template>
    <div>
		<el-button type="primary" 
			style="float: right;position: relative;top: -20px;"
			@click="downLode"
			size="mini">导出</el-button>
        <el-table  :data="list"  
			 border  
			 style="width: 100%"
			>
			
			<el-table-column  align="center" width="220"  prop="code" label="串号" />
			<el-table-column  align="center" width="250"  prop="goods_name" label="商品名称" />
			<el-table-column  align="center"  width="120"  prop="goods_type" label="商品分类" />
			<el-table-column  align="center"  width="120"  prop="brand" label="商品品牌" />
			<el-table-column  align="center" width="120"  prop="price" label="采购单价" />
			<el-table-column  align="center" width="100"  prop="supplier" label="供应商" />
			<el-table-column  align="center" width="120"  prop="buyer_date" label="入库日期" />
            <!-- <el-table-column   align="center" 
				label="入库方式">
				<template slot-scope="scope">
				   <div>
						{{['退货','入库','销售'][scope.row.status]}}
				   </div>
				</template>
			</el-table-column> -->
			<el-table-column  align="center"  width="240"  prop="remark" label="备注" />
			<!-- <el-table-column   align="center"  width="130px"  label="备注">
				<template slot-scope="scope">
				   <div>
						<el-input  size="mini" v-model="scope.row.remark"></el-input>
				   </div>
				</template>
			</el-table-column> -->
			
		</el-table>
        <div class="page">
            <el-pagination
                    background
                    @size-change="pageChange"
                    @current-change="handleCurrentChange"
                    :current-page="page"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="page_totle">
            </el-pagination>
        </div>
		<br><br>
		
		<el-dialog
		        title="编辑"
				:close-on-click-modal="false"
				:append-to-body="true"
		        :visible.sync="isShow"
		        width="700px"
		>
		    <el-form  :model="form" label-width="120px">
		        <el-form-item label="串号">
		            <el-input v-model="form.code" style="width: 500px"></el-input>
		        </el-form-item>
		        <el-form-item label="商品名称">
		            <el-input v-model="form.goods_name" style="width: 500px"></el-input>
		        </el-form-item>
				<el-form-item label="商品类型">
				    <el-input v-model="form.goods_type" style="width: 500px"></el-input>
				</el-form-item>
				<el-form-item label="商品品牌">
				    <el-input v-model="form.brand" style="width: 500px"></el-input>
				</el-form-item>
				<el-form-item label="采购单价">
				    <el-input v-model="form.price" style="width: 500px"></el-input>
				</el-form-item>
				<el-form-item label="供应商">
				    <el-input v-model="form.supplier" style="width: 500px"></el-input>
				</el-form-item>
		    </el-form>
		    <span slot="footer" class="dialog-footer">
		            <el-button size="small" @click="isShow = false">取 消</el-button>
		            <el-button size="small" type="primary" @click="confirm">确 定</el-button>
		        </span>
		</el-dialog>
		
		
    </div>
</template>
<script>
    export default {
        props:{
			goods_name:{
				type:String,
				default:''
			},
			is_jc:{
				type:Boolean,
				default:false
			},
			supplier:{
				type:String,
				default:''
			}
		},
        data(){
            return {
				pageSize:10,
				page:1,
				page_totle:0,
				form:{
					code:"",
					goods_name:"",
					goods_type:"",
					brand:"",
					price:"",
					supplier:'',
					id:''
				},
				isShow:false
            }
        },
        mounted(){
		    this.lodeList()
        },
        methods:{
			downLode(){
				let cid = sessionStorage.getItem('cid')
				
				 var goods_name
				 if(this.goods_name){
					goods_name = '&goods_name=' + this.goods_name
				 }else{
					goods_name = '&goods_name='
				 }
				 
				 var is_jc
				 if(this.is_jc){
				 	 is_jc = '&is_jc=' + this.is_jc
				 }else{
				 	 is_jc = '&is_jc='
				 }
				
				let url = `${this.$domain}/excel/exportInventoryGoods?cid=${cid}${goods_name}${is_jc}`
				location.href = url
			},
			// delRow(row){
			// 	this.$confirm('确定删除?', '提示', {
			// 	          confirmButtonText: '确定',
			// 	          cancelButtonText: '取消',
			// 	          type: 'warning'
			// 	        }).then(() => {
			// 				let params = {
			// 					id:row.id,
			// 					goods_name:row.goods_name
			// 				}
			// 				this.$post('/buyerSysUpdate/delOneInventory',params,res=>{
			// 					this.$message.success('操作成功')
			// 					this.$emit('onSuccess')
								
			// 				})
			// 	        })
			// },
			confirm(){
				this.$post('/buyerSysUpdate/editOneInventory',this.form,res=>{
					this.$message.success('操作成功')
					this.$emit('onSuccess')
					this.isShow = false
				})
			},
			editRow(row){
				for(let i in this.form){
					this.form[i] = row[i]
				}
				this.isShow = true
			},
			lodeList(){
				let params = {
					goods_name:this.goods_name,
					page:this.page,
					pageSize:this.pageSize,
					is_jc:this.is_jc,
					supplier:this.supplier
				}
				this.$post('/buyerSys/getGoodsForGoodsName',params,res=>{
					let data = res.data.data
					this.page_totle = data.count
					this.list = data.result
				})
			},
        }
    }
</script>
